package com.qf.business.system.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.qf.data.system.dto.RoleDto;
import com.qf.data.system.dto.RoleDto2;
import com.qf.data.system.entity.Role;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 角色表(Role)表数据库访问层
 *
 * @author makejava
 * @since 2022-05-26 16:17:12
 */
public interface RoleMapper extends BaseMapper<Role> {

    @Select("select *, (select dep_name from department where id = r.dep_id) as depName from role r")
    List<RoleDto> queryList();

    @Select("select *,(select count(*) from emp_role_table where rid = r.id and eid = #{empId}) as isChecked \n" +
            "from role r where dep_id = #{depId}")
    List<RoleDto2> queryRoleByDepAndEmp(@Param("depId") Long depId, @Param("empId") Long empId);
}


